GHashTable *sending_messages; /* SoupMessage */
GHashTable *message_to_request; /* SoupMessage -> SoupRequest */
+ GHashTable *output_stream_set; /* set<GOutputStream> */
guint64 total_downloaded;
guint total_requests;
g_hash_table_destroy (self->sending_messages);
g_hash_table_destroy (self->message_to_request);
+ g_hash_table_destroy (self->output_stream_set);
g_queue_clear (&self->pending_queue);
(GDestroyNotify)g_object_unref);
self->message_to_request = g_hash_table_new_full (NULL, NULL, (GDestroyNotify)g_object_unref,
(GDestroyNotify)pending_uri_free);
+ self->output_stream_set = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_object_unref);
}
OstreeFetcher *
goffset filesize;
GError *local_error = NULL;
+ if (pending->out_stream)
+ g_hash_table_remove (pending->self->output_stream_set, pending->out_stream);
+
pending->state = OSTREE_FETCHER_STATE_COMPLETE;
file_info = g_file_query_info (pending->out_tmpfile, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
pending->cancellable, &local_error));
if (!pending->out_stream)
goto out;
+ g_hash_table_add (pending->self->output_stream_set, g_object_ref (pending->out_stream));
g_output_stream_splice_async (pending->out_stream, pending->request_body, flags, G_PRIORITY_DEFAULT,
pending->cancellable, on_splice_complete, pending);
+
}
else
{
guint64
ostree_fetcher_bytes_transferred (OstreeFetcher *self)
{
- return self->total_downloaded;
+ guint64 ret = self->total_downloaded;
+ GHashTableIter hiter;
+ gpointer key, value;
+
+ g_hash_table_iter_init (&hiter, self->output_stream_set);
+ while (g_hash_table_iter_next (&hiter, &key, &value))
+ {
+ GFileOutputStream *stream = key;
+ GFileInfo *finfo;
+
+ finfo = g_file_output_stream_query_info (stream, "standard::size",
+ NULL, NULL);
+ if (finfo)
+ {
+ ret += g_file_info_get_size (finfo);
+ g_object_unref (finfo);
+ }
+ }
+
+ return ret;
}
guint